package cn.geekhalo.auth.domain;

import cn.geekhalo.common.support.AbstractEntity;
import com.google.common.collect.Sets;
import lombok.Data;

import javax.persistence.*;
import java.util.Set;

@Table(name = "tb_role")
@Entity
@Data
public class Role extends AbstractEntity {

    @Column(name = "role_name")
    private String roleName;

    @Column(name = "role_code")
    private String roleCode;

    @ManyToMany(cascade = CascadeType.REMOVE,fetch = FetchType.LAZY)
    @JoinTable(name = "tb_role_resource",joinColumns = @JoinColumn(name="role_id",referencedColumnName = "id"),inverseJoinColumns = @JoinColumn(name = "resource_id",referencedColumnName = "id"))
    private Set<Resource> resources = Sets.newHashSet();

}
